package dyyx.agent.main;
import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.IllegalClassFormatException;
import java.lang.instrument.Instrumentation;
import java.security.ProtectionDomain;

public class MainAgent {

	 public static void agentmain(String agentArgs, Instrumentation instrumentation) {
	        System.out.println("MainAgent agentArgs: " + agentArgs);

	        Class<?>[] classes = instrumentation.getAllLoadedClasses();
	        for (Class<?> cls : classes) {
	            System.out.println("MainAgent get loaded class: " + cls.getName());
	        }

	        instrumentation.addTransformer(new MainAgentTransformer(), true);
	    }

	    static class MainAgentTransformer implements ClassFileTransformer {

	        @Override
	        public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
	            System.out.println("MainAgent transform Class:" + className);
	            return classfileBuffer;
	        }
	    }
	    
	    
}
